﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Automobile.service.BLL;
using Automobile.service.Model;
using System.Data;

namespace Automobile.service.UI
{
    public partial class Employee_Edit : System.Web.UI.Page
    {
        EmployeeBLL bll = new EmployeeBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int id = Convert.ToInt32(Request.QueryString["eid"]);
                DataTable table = bll.GetEmployeeByempid(id);
                this.HiddenField1.Value = id.ToString();
                Employee_Name.Value = table.Rows[0]["Employee_Name"].ToString();
                Employee_Pwd.Value = table.Rows[0]["Employee_Pwd"].ToString();
                Employee_Phone.Value = table.Rows[0]["Employee_Phone"].ToString();
                Employee_Addr.Value = table.Rows[0]["Employee_Addr"].ToString();
                Employee_Remark.Value = table.Rows[0]["Employee_Remark"].ToString();
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Employee emp = new Employee();
            emp.Employee_Id = int.Parse(HiddenField1.Value);
            emp.Employee_Name = Employee_Name.Value;
            emp.Employee_Pwd = Employee_Pwd.Value;
            emp.Employee_Phone = Employee_Phone.Value;
            emp.Employee_Addr = Employee_Addr.Value;
            emp.Employee_Remark = Employee_Remark.Value;
            if (bll.UpdEmployeeByempid(emp) > 0)
            {
                JournalBLL jbll = new JournalBLL();
                jbll.AddJourna_UpdEmployeeByempid(Convert.ToInt32(Session["empid"]), emp);
                Response.Write("<script>alert('修改成功！');parent.location.reload(); parent.layer.close(parent.layer.getFrameIndex(window.name));</script>");
            }
            else
            {
                Response.Write("<script>alert('修改失败！'); parent.layer.close(parent.layer.getFrameIndex(window.name));</script>");
            }
        }
    }
}